#include <iostream>
#include <optional>
#include <vector>

std::optional<int> FindByIndex(std::vector<int> & v,int index)
{
    if(index < 0)
        return std::nullopt;//空对象
    int a = v[index];
    return a;
}

int main()
{
    std::vector<int> v = {1,2,3};
    auto value = FindByIndex(v,1);
    if(value)
        std::cout<<*value<<std::endl;
    else
        std::cout<<"没找到"<<std::endl;
    return 0;
}